package com.commons.tools.multiconn.common2;

import com.commons.tools.multiconn.IService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.Map;

/**
 * <p></p>
 *
 * @author 
 * @date 2022/5/18
 */
@Service
public class BizServiceLoader {

    private Map<String, IService> map;
    private Map<String, Class<?>> tmap;

    @Autowired
    ApplicationContext applicationContext;

    @PostConstruct
    public void init() {
        //根据接口类型返回相应的所有bean
        if (map != null) {
            return;
        }
        map = applicationContext.getBeansOfType(IService.class);
    }

    public Map<String, IService> getMap() {
        return map;
    }
}
